/**
 * 修改树的数据，将name字段属性改为label
 */
export function changeTreeData(tree) {
  const resultList = []
  tree2List(tree, resultList)
  resultList.map(item => {
    item.label = item.name
    return item
  })
  return tree
}

/**
 * 树转列表
 */
export function tree2List(tree, resultList) {
  tree.forEach(item => {
    if (item.children && item.children.length > 0) {
      tree2List(item.children, resultList)
    } else {
      resultList.push(item)
    }
  })
}
